<!DOCTYPE html>
<html >

<head>

  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Reproducible and scalable workflows with Snakemake</title>
  <meta name="description" content="Reproducible and scalable workflows with Snakemake">
  <meta name="generator" content="bookdown 0.7 and GitBook 2.6.7">

  <meta property="og:title" content="Reproducible and scalable workflows with Snakemake" />
  <meta property="og:type" content="book" />
  
  
  
  

  <meta name="twitter:card" content="summary" />
  <meta name="twitter:title" content="Reproducible and scalable workflows with Snakemake" />
  
  
  

<meta name="author" content="Shaojun Xie">


<meta name="date" content="2018-12-30">

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  
  
<link rel="prev" href="read-httpsgroups-google-comforumsearchinsnakemakedependenciessnakemakeidnr3picsfex-qqvzwbbgaj.html">

<script src="libs/jquery-2.2.3/jquery.min.js"></script>
<link href="libs/gitbook-2.6.7/css/style.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-bookdown.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-highlight.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-search.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-fontsettings.css" rel="stylesheet" />










<link rel="stylesheet" href="style.css" type="text/css" />
</head>

<body>



  <div class="book without-animation with-summary font-size-2 font-family-1" data-basepath=".">

    <div class="book-summary">
      <nav role="navigation">

<ul class="summary">
<li><a href="./">Snakemake book</a></li>

<li class="divider"></li>
<li class="chapter" data-level="1" data-path="index.html"><a href="index.html"><i class="fa fa-check"></i><b>1</b> Prerequisites</a></li>
<li class="chapter" data-level="2" data-path="intro.html"><a href="intro.html"><i class="fa fa-check"></i><b>2</b> Introduction</a><ul>
<li class="chapter" data-level="2.1" data-path="intro.html"><a href="intro.html#installation"><i class="fa fa-check"></i><b>2.1</b> Installation</a><ul>
<li class="chapter" data-level="2.1.1" data-path="intro.html"><a href="intro.html#recommended-way-to-install-snakemake"><i class="fa fa-check"></i><b>2.1.1</b> Recommended way to install <code>snakemake</code></a></li>
</ul></li>
</ul></li>
<li class="chapter" data-level="3" data-path="read-httpsgroups-google-comforumsearchinsnakemakedependenciessnakemakeidnr3picsfex-qqvzwbbgaj.html"><a href="read-httpsgroups-google-comforumsearchinsnakemakedependenciessnakemakeidnr3picsfex-qqvzwbbgaj.html"><i class="fa fa-check"></i><b>3</b> read <a href="https://groups.google.com/forum/#!searchin/snakemake/dependencies/snakemake/iDnr3PIcsfE/x-qQvzWBBgAJ" class="uri">https://groups.google.com/forum/#!searchin/snakemake/dependencies/snakemake/iDnr3PIcsfE/x-qQvzWBBgAJ</a></a></li>
<li class="chapter" data-level="4" data-path="httpsgroups-google-comforumsearchinsnakemakedependenciessnakemake1qelazgzilyobgzop19bl4j.html"><a href="httpsgroups-google-comforumsearchinsnakemakedependenciessnakemake1qelazgzilyobgzop19bl4j.html"><i class="fa fa-check"></i><b>4</b> <a href="https://groups.google.com/forum/#!searchin/snakemake/dependencies/snakemake/1QelazgzilY/oBgZoP19BL4J" class="uri">https://groups.google.com/forum/#!searchin/snakemake/dependencies/snakemake/1QelazgzilY/oBgZoP19BL4J</a></a></li>
<li class="divider"></li>
<li><a href="https://github.com/rstudio/bookdown" target="blank">Published with bookdown</a></li>

</ul>

      </nav>
    </div>

    <div class="book-body">
      <div class="body-inner">
        <div class="book-header" role="navigation">
          <h1>
            <i class="fa fa-circle-o-notch fa-spin"></i><a href="./">Reproducible and scalable workflows with Snakemake</a>
          </h1>
        </div>

        <div class="page-wrapper" tabindex="-1" role="main">
          <div class="page-inner">

            <section class="normal" id="section-">
<div id="httpsgroups.google.comforumsearchinsnakemakedependenciessnakemake1qelazgzilyobgzop19bl4j" class="section level1">
<h1><span class="header-section-number">Chapter 4</span> <a href="https://groups.google.com/forum/#!searchin/snakemake/dependencies/snakemake/1QelazgzilY/oBgZoP19BL4J" class="uri">https://groups.google.com/forum/#!searchin/snakemake/dependencies/snakemake/1QelazgzilY/oBgZoP19BL4J</a></h1>
<p>aDict = {“B”:“inputG1”, “A”:“inputG1”, “C”:“inputG2”}</p>
<p>rule all: input: [“C.bed”, “A.bed”, “B.bed”]</p>
<p>def get_files(wildcards): case = wildcards.case control = aDict[case] return [case + “.sorted.bam”, control + “.sorted.bam”]</p>
<p>rule call_peak: input: get_files output: “{case}.bed” shell: “”&quot; echo macs14 -t {input[0]} -c {input[1]} -n {wildcards.case} touch {output} “”&quot;</p>
<pre><code>

## Convert dictionary content to `wildcards`

</code></pre>
<p>SAMPLES=“BMAL1-ZT10_rep1 BMAL1-ZT10_rep2 BMAL1-ZT22_rep1”.split() COMPARES={ “10vs22” : (“BMAL1-ZT10_rep1 BMAL1-ZT10_rep2”.split(), [“BMAL1-ZT22_rep1”]), “r1vsr2” : ([“BMAL1-ZT10_rep1”], [“BMAL1-ZT10_rep2”])}</p>
<p>rule All: input: expand(“diffexp/{compare}.diff”, compare=COMPARES.keys()) rule GfoldDiff: input: expand(“diffexp/{sample}.cnt”, sample=COMPARES[“{wildcards.compare}”]) output: “diffexp/{compare}.diff”</p>
<pre><code>
</code></pre>
<p>def gfold_group1(wildcards): return [“diffexp/{0}.cnt”.format(i) for i in COMPARES[wildcards.compare][0]] def gfold_group2(wildcards): return [“diffexp/{0}.cnt”.format(i) for i in COMPARES[wildcards.compare][1]] rule GfoldDiff: input: group1=gfold_group1,group2=gfold_group2 output: “diffexp/{compare}.diff” run: shell(“gfold diff -s1 {group1} -s2 {group2} -o {output}”.format( group1=“,”.join(group1), group2=“,”.join(group2), output=output)) ```</p>

</div>
            </section>

          </div>
        </div>
      </div>
<a href="read-httpsgroups-google-comforumsearchinsnakemakedependenciessnakemakeidnr3picsfex-qqvzwbbgaj.html" class="navigation navigation-prev navigation-unique" aria-label="Previous page"><i class="fa fa-angle-left"></i></a>

    </div>
  </div>
<script src="libs/gitbook-2.6.7/js/app.min.js"></script>
<script src="libs/gitbook-2.6.7/js/lunr.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-search.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-sharing.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-fontsettings.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-bookdown.js"></script>
<script src="libs/gitbook-2.6.7/js/jquery.highlight.js"></script>
<script>
gitbook.require(["gitbook"], function(gitbook) {
gitbook.start({
"sharing": {
"github": false,
"facebook": true,
"twitter": true,
"google": false,
"linkedin": false,
"weibo": false,
"instapper": false,
"vk": false,
"all": ["facebook", "google", "twitter", "linkedin", "weibo", "instapaper"]
},
"fontsettings": {
"theme": "white",
"family": "sans",
"size": 2
},
"edit": {
"link": null,
"text": null
},
"download": ["snakemake_book.pdf", "snakemake_book.epub"],
"toc": {
"collapse": "subsection"
}
});
});
</script>

</body>

</html>
